package sz.szsmk.citizencard.ui.adapter;

import android.content.Context;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.List;

import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.model.network.bean.response.QueryAllFunctionNewRes;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/12/24 10:51
 * description:
 */
public class GoverHeadIconAdapter extends RecyclerView.Adapter<GoverHeadIconAdapter.GoverHeadIconHolder> {
    private Context mContext;
    private List<QueryAllFunctionNewRes.ClassListBean.FunctionListBean> viewData;

    public GoverHeadIconAdapter(FragmentActivity activity) {
        mContext = activity;
    }

    @Override
    public GoverHeadIconHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.gover_head_iconview, parent, false);
        return new GoverHeadIconHolder(view);
    }

    @Override
    public void onBindViewHolder(GoverHeadIconHolder holder, int position) {
        if (viewData != null) {
            Glide.with(mContext)
                    .load(viewData.get(position).getIcon_url())
                    .into(holder.headIcon);

        }
    }

    @Override
    public int getItemCount() {
        return null == viewData ? 0 : viewData.size();
    }

    public void setViewData(List<QueryAllFunctionNewRes.ClassListBean.FunctionListBean> viewData) {
        this.viewData = viewData;
    }

    public static class GoverHeadIconHolder extends RecyclerView.ViewHolder {

        private final ImageView headIcon;

        public GoverHeadIconHolder(View itemView) {
            super(itemView);
            headIcon = (ImageView) itemView.findViewById(R.id.head_ic);
        }
    }

}
